package com.tong.embeddedvr.config;

import com.tong.embeddedvr.interceptor.WebSocketInterceptor;
import com.tong.embeddedvr.websocket.WebSocketHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * TODO
 *
 * @author gcl
 * @version 1.0
 * @Description
 * @date 2021/3/4 17:14
 */
@Configuration
@EnableWebSocket
public class WebSSHWebSocketConfig implements WebSocketConfigurer {

    @Autowired
    WebSocketHandler webSocketHandler;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
        //addHandler第二个参数是绑定的路径
        webSocketHandlerRegistry.addHandler(webSocketHandler,"/webshell").addInterceptors(new WebSocketInterceptor()).setAllowedOrigins("*");
    }
}
